﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using JMR.Components;

namespace JMR.Applications.ScreenCapture
{
    public partial class FormMain : Form
    {
        private Screenshot scr = null;

        public FormMain()
        {
            InitializeComponent();
            btnSave.Enabled = false;
            btnTakeScreenshot.Enabled = false;
            btnStartCapturing.Enabled = true;
        }

        private void btnStartCapturing_Click(object sender, EventArgs e)
        {
            btnStartCapturing.Enabled = false;
            btnTakeScreenshot.Enabled = true;
            scr = new Screenshot(this);
            scr.showFrame();
        }

        private void btnTakeScreenshot_Click(object sender, EventArgs e)
        {
            btnStartCapturing.Enabled = true;
            btnTakeScreenshot.Enabled = false;
            pictureBox1.Image = scr.TakeScreenshot(false);
            btnSave.Enabled = true;
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            saveFileDialog.Filter = "Supported Format *.png|*.png";
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                pictureBox1.Image.Save(saveFileDialog.FileName);
            }
        }
    }
}
